<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>课程内容</title>
    <link rel="stylesheet" href="/lib/layui/css/layui.css">
    <link rel="stylesheet" href="/css/attend/m/common.css">
    <link rel="stylesheet" href="/lib/layui/layui/css/eleTree.css">
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css">
    <script src="/lib/layui/layui/layui.js"></script>
    <script type="text/javascript" src="/lib/layui/layui/global.js"></script>
    <script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.ui.widget.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.iframe-transport.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jQuery-File-Upload-master/jquery.fileupload.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/ajaxupload.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/jquery.form.min.js"></script>
    <script type="text/javascript" src="/js/common/fileupload.js"></script>
    <script src="/js/base/base.js" type="text/javascript" charset="utf-8"></script>
    <script src="/lib/layui/layui/js/common.js" type="text/javascript" charset="utf-8"></script>
    <script src="/ui/lib/layui/layui/js/baseCode/base.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="/js/meeting/jquery.qrcode.min.js"></script>
    <style>
        html, body {
            width: 100%;
            height: 99%;
        }

        .layui-card-header {
            border-bottom: 1px solid #eee;
        }

        .mbox {
            /*padding: 8px;*/
            height: 98%;
        }

        .inbox {
            padding: 5px;
            padding-right: 30px;
        }

        .deptinput {
            display: inline-block;
            width: 75%;
        }

        .layui-btn {
            margin-left: 10px;
        }

        .layui-btn .layui-icon {
            margin-right: 0px;
        }

        .red {
            color: red;
            font-size: 16px;
        }

        .layui-form-label {
            padding: 8px 15px;
        }

        .layui-card-body {
            display: flex;
        }

        .layui-lf {
            min-width: 16%;
            overflow-x: auto;
            height: 600px !important;
        }

        .layui-rt {
            width: 100%;
            margin-left: 6px;
            margin-top: -10px;
        }

        .treeTitle {
            display: flex;
            box-sizing: border-box;
            justify-content: center;
            align-items: center;
            width: 100%;
            height: 30px;
            background-color: #00a0e9;
            color: #fff;
            padding: 15px;
            position: relative;
        }

        .layui-nav-item, .layadmin-flexible {
            position: absolute;
            left: 5px;
            top: 23px;
            z-index: 9999999;
        }

        .rtfix {
            overflow-y: auto;
        }

        .bg {
            background-color: #F2F2F2;
        }

        .bgs {
            background-color: #F2F2F2;
        }

        /*滚动条样式*/
        .rtfix::-webkit-scrollbar { /*滚动条整体样式*/
            width: 4px; /*高宽分别对应横竖滚动条的尺寸*/
            height: 4px;
        }

        .rtfix::-webkit-scrollbar-thumb { /*滚动条里面小方块*/
            border-radius: 5px;
            -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
            background: rgba(0, 0, 0, 0.2);
        }

        .rtfix::-webkit-scrollbar-track { /*滚动条里面轨道*/
            -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
            border-radius: 0;
            background: rgba(0, 0, 0, 0.1);
        }

        .eleTree {
            cursor: pointer;
        }

        .layui-table-view .layui-table td, .layui-table-view .layui-table th {
            padding: 3px 0;
        }

        .layui-tab-title {
            height: 30px;
        }

        .layui-tab-title li {
            height: 36px;
            margin-top: -5px;
        }

        .layui-tab layui-tab-card {
            margin-top: -4px;
        }

        .layui-tab-card > .layui-tab-title .layui-this:after {
            border-width: 0px;
        }

        .baseinfo td {
            padding: 5px 2px;
        }

        .active {
            display: none;
        }

        .layui-inline {
            width: 47%;
        }

        .layui-form-label {
            width: 125px;
        }

        .codes {
            float: left;
            margin-right: 20px;
            width: 30%;
        }

    </style>
</head>
<body>
<div id="codeCon" style="display: none;text-align: center">
    <div class="codes" style=" float: left;margin-right: 20px; width: 30%;">
    <div style="margin: 20px 0px;font-size: 18px;">报名二维码</div>
    <div id="qcode2" ></div>
    </div>-
    <div class="codes" style=" margin-right: 20px; width: 30%;">
        <div style="margin: 20px 0px;font-size: 18px;">签到二维码</div>
        <div id="qcode"></div>
    </div>

    <div class="codes" style=" float: left;margin-right: 20px; width: 30%;">
    <div style="margin: 20px 0px;font-size: 18px;">评估二维码</div>
    <div id="qcode3" ></div>
    </div>
    <div style="width: 100%;text-align: center;float: left;">
        <button class="layui-btn layui-btn-sm " lay-event="" style="width: 70px;margin-top: 20px;" id="print">打印
        </button>
        <button class="layui-btn layui-btn-sm back" lay-event="back" style="width: 70px;margin-top: 20px;" >
            返回
        </button>
    </div>

</div>

<div class="mbox">

    <div class="layui-card">
        <div class="layui-card-body" style="padding-left: 6px;">

            <div class="layui-rt" style="position: relative">
                <table id="Settlement" lay-filter="SettlementFilter">

                </table>

            </div>

        </div>
    </div>

</div>
<script type="text/html" id="toolbar">
    <%--<div class="demoTable" style="float: right; margin-right:9px;margin-top: -1px;">--%>
        <%--搜索：--%>
        <%--<div class="layui-inline">--%>
            <%--<input class="layui-input" name="id" id="demoReloads" autocomplete="off" style="height: 32px;">--%>
        <%--</div>--%>
        <%--<button class="layui-btn" data-type="reload" style="height:30px;line-height: 30px">搜索</button>--%>
    <%--</div>--%>
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="add" style="width: 70px" id="addEq">新增</button>
        <%--<button class="layui-btn layui-btn-sm back" lay-event="back" style="width: 70px" id="back">返回</button>--%>
        <%--<button class="layui-btn layui-btn-sm" lay-event="pedit" style="width: 70px" >批量修改</button>--%>
        <%--<button class="layui-btn layui-btn-sm" lay-event="pdel" style="width: 70px" onclick="doRemoveBatch()">批量删除</button>--%>
        <%--<button class="layui-btn layui-btn-sm" lay-event="import" style="width: 70px">导入</button>--%>
    </div>
</script>

<script type="text/html" id="toolbars">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="add" style="width: 70px" href="/equipCert/addvice">新增</button>
        <button class="layui-btn layui-btn-sm" lay-event="pedit" style="width: 70px">批量修改</button>
    </div>
</script>

<script type="text/html" id="barOperation">
    <%--<a class="layui-btn layui-btn-xs" lay-event="fabu" id="fabu">发布</a>--%>
    <a class="layui-btn layui-btn-xs" lay-event="courseCon" id="erwei">二维码</a>
    <%--<a class="layui-btn layui-btn-xs" lay-event="detail" id="detail">课程详情</a>--%>
    <a class="layui-btn layui-btn-xs" lay-event="edit" id="edit1">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    <a class="layui-btn  layui-btn-xs" lay-event="person" >人员信息</a>
    <%--<a class="layui-btn  layui-btn-xs" lay-event="import" >签到导入</a>--%>
</script>
<script type="text/javascript">
    var parentcourseId = $.GetRequest().courseId
    var parentcourseName= ''
    var parentcourseType = $.GetRequest().courseType
    var parentType = $.GetRequest().type;
    var parentTeacher = '';
    var schedule=""
    var courseName=''
    if (parentType == 0) {
        $('.mbox').show();
        $('#codeCon').hide();
    } else {
        $('.mbox').hide();
        $('#codeCon').show();
    }
    $.ajax({
        url:'/trCourse/showDetils?courseId='+parentcourseId,
        dataType:'json',
        type:'get',
        success:function(res){
            parentcourseName=res.object.courseName;
            parentTeacher = res.object.courseLecturer;
        }
    })
    var courseTypeId = ''
    var el
        , aldata
        , newstr = '<div class="iptbox mnodec" pid="">' +
        '<input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="序号" class="layui-input pnul">' +
        '<input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="名称" class="layui-input shorts">' +
        '<input type="text" name="title" lay-verify="title" autocomplete="off" placeholder="备注" class="layui-input longs">' +
        '<div class="btnls">' +
        '<button type="button" class="layui-btn layui-btn-primary layui-btn-sm limsAdd"><i class="layui-icon"></i></button>' +
        '<button type="button" class="layui-btn layui-btn-primary layui-btn-sm limsDel"><i class="layui-icon"></i></button>' +
        '</div>' +
        '</div>';
    var resultTypeData = '';
    var a = "";
    $('.rtfix').css('max-height', autodivheight() - 55)
    var tableObj;

    layui.use(['table', 'layer', 'laydate', 'form', 'element', 'eleTree'], function () {
        var table = layui.table;
        var layer = layui.layer;
        var form = layui.form;
        var laydate = layui.laydate;
        var eleTree = layui.eleTree;
        var element = layui.element;
        var $ = layui.jquery;
        //第一个实例
        tableObj = table.render({
            elem: '#Settlement'
            , url: '/trCourseSchedule/showSome?courseId=' + parentcourseId //数据接口
            , page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['prev', 'page', 'next', 'skip', 'count', 'limit',]//自定义分页布局
                , limits: [5, 10, 15, 20, 25, 30, 35, 40, 45, 50]
                , first: false //不显示首页
                , last: false //不显示尾页
            } //开启分页
            , toolbar: '#toolbar'
            , cols: [[ //表头
                {type: 'checkbox'}
                , {type: 'numbers', title: '序号'}
                , {field: 'courseId', title: 'id', hide: true}
                , {field: 'scheduleName', title: '课程名称'}
                , {field: 'classHour', title: '课时'}
                , {field: 'courseLecturer', title: '讲师'}
                , {field: 'signUps', title: '报名人数'}
                , {field: 'coursePeople', title: '参训人数'}
                , {field: 'assessDegree', title: '评估满意度'}
                // , {field: 'courseState', title: '状态',templet:function(d){
                //         if(d.courseState == 0){
                //             return '未发布'
                //         }else{
                //             return '已发布'
                //         }
                //     }}
                , {fixed: 'right', width: 300, fixed:'right',title: '操作', align: 'center', toolbar: '#barOperation'}
            ]]

            , limit: 10
            , done: function (res) {
                for(var i=0;i<res.data.length;i++){
                    if(res.data[i].courseState == '0'){
                        $('tr[data-index="'+i+'"]').find('#fabu').text('发布')
                    }else{
                        $('tr[data-index="'+i+'"]').find('#fabu').text('取消发布')
                    }
                    if(parentcourseType== 0){
                        $('tr[data-index="'+i+'"]').find('#erwei').show()
                    }else{
                        $('tr[data-index="'+i+'"]').find('#erwei').show()
                    }
                }
                /*     // $('.hide').attr('dataType','0')
                     $.get('/equipmentCapys/selectByEquipId',{equipId:res.data[0].equipId},function (res) {
                         resultTypeData = res.data;
                         var str="";
                         for(var i=0;i<resultTypeData.length;i++){
                             str += '<tr>' +
                                 '<td style="color: #111;">'+resultTypeData[i].capyName+'</td>' +
                                 '<td idx="'+i+'" typename="capyInitialValue" class="edit" style="color: #111;">'+undefind_nullStr(resultTypeData[i].capyInitialValue)+'</td>' +
                                 '<td idx="'+i+'" typename="calibrationValue"  class="edit" style="color: #111;">'+undefind_nullStr(resultTypeData[i].calibrationValue)+'</td>' +
                                 '</tr>';
                         }
                         $(".total").html(str)
                         form.render();
                     })*/
            }
        });

        function undefind_nullStr(value) {
            if (value == undefined) {
                return ""
            }
            return value
        }

        //监听复选框事件
        table.on('checkbox(SettlementFilter)', function (obj) {
            var tr = obj.tr[0];
            if (obj.checked) {
                $(tr).addClass('bgs')
            } else {
                $(tr).removeClass('bgs').removeClass('bg')
            }
        });

        $('.back').click(function () {
            $('.mbox').show();
            $('#codeCon').hide();
        })
        table.on('toolbar(SettlementFilter)', function (obj) {
            switch (obj.event) {
                case 'add':
                    editAdd(0, 0);
                    break;
                case 'back':
                    window.location.href = '/course/index';
                    break;
            }
            ;
        });
// 编辑/删除操作
        table.on('tool(SettlementFilter)', function (obj) {//注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的DOM对象
            var scheduleId = data.scheduleId;
            var urlTitle = '/trCourseSchedule';
            if (layEvent === 'del') { //删除
                // layer.confirm('确认删除', function(index){
                publicDeletes(urlTitle + "/delete", scheduleId + "", tableObj, table);
                //向服务端发送删除指令
                // });
            } else if (layEvent === 'edit') { //编辑
                editAdd(1, scheduleId);
            } else if (layEvent === 'detail') {
                editAdd(2, scheduleId);

            }else if(layEvent === 'person'){
                layer.open({
                    type: 2,
                        title:'人员信息',
                        area:['90%','80%'],
                    content: '/course/personInformation?courseId='+parentcourseId+'&scheduleId='+scheduleId
                });
                // layer.open({
                //     type:'2',
                //     title:'人员信息',
                //     area:['90%','80%'],
                //     content:
                // })
                // $.popWindow(,'课程排课', '', '', '800px', '600px')

            }else if(layEvent === 'courseCon'){

                schedule = scheduleId;

                courseName= data.scheduleName;
                    $('.mbox').hide();
                    $('#codeCon').show();
                    $('#qcode').html('')
                $('#qcode2').html('')
                $('#qcode3').html('')
                $('#qcode').qrcode(window.location.protocol + '//' + window.location.host + '/signIn/signh5?courseId=' + parentcourseId +'&scheduleId='+schedule+ '&type=0');
                $('#qcode2').qrcode(window.location.protocol + '//' + window.location.host + '/signIn/signh5?courseId=' + parentcourseId +'&scheduleId='+schedule+ '&type=1&studyTime=1000');
                $('#qcode3').qrcode(window.location.protocol + '//' + window.location.host + '/signIn/signh5?courseId=' + parentcourseId + '&scheduleId='+schedule+ '&type=2');

            }else if(layEvent === 'fabu'){
                var data = {scheduleId:scheduleId}
                if($(this).text() == '发布'){
                    data.courseState = '发布'
                }else{
                    data.courseState = '取消发布'
                }
                $.ajax({
                    url:'/trCourseSchedule/changeState',
                    type:'get',
                    data:data,
                    dataType:'json',
                    success:function(res){
                        var currentPage = 1
                        table.reload('Settlement',{
                            url : '/trCourseSchedule/showSome?courseId='+parentcourseId,
                            data:{page:currentPage},
                            page:{
                                curr:currentPage
                            }
                        })
                    }
                })
            }
        });
        $('#fixed').click(function (e) {
            e.stopPropagation();
            $('table').width('100%')
            if ($(this).attr('dataType') != 1) {
                $('.layui-lf').fadeOut();
                $('.layui-rt').animate({width: '100%'});
                $(this).attr('dataType', '1');
            } else {
                $('.layui-lf').fadeIn();
                $('.layui-rt').animate({width: '84%'});
                $(this).attr('dataType', '0');
            }

        })


        $(function () {

        })

//编辑添加layer
        function editAdd(type, courseId) {
            var title = "编辑";
            if (type == 0) {
                title = "新增排课信息";
            } else if (type == 1) {
                title = "编辑";
            } else {
                title = "课程排课详情";
            }

            var index = layer.open({
                type: 1,
                skin: 'layui-layer-rim', //加上边框
                area: ['900px', '80%'], //宽高
                shadeClose:true,
                title: title,
                maxmin: true,
                btn: ['<div style="background:none;border:none;color:#fff" id="lay-submit">确定</div>', '取消'],
                content: '<div class="layui-card"><form class="layui-form" id="ajaxform" action="">' +
                    '<div class="layui-form-item" style="margin-top:10px;">\n' +
                    ' \n' +
                    '  <div class="layui-inline">\n' +
                    '    <label class="layui-form-label">课程名称</label>\n' +
                    '    <div class="layui-input-inline" style="">\n' +
                    '      <input type="text" name="scheduleName" value="'+parentcourseName+'"  placeholder="" autocomplete="off" class="layui-input">\n' +
                    '    </div>\n' +
                    '  </div>\n' +
                     '  \n' +
                      '  <div class="layui-inline">\n' +
                      '    <label class="layui-form-label">课程类型</label>\n' +
                      '    <div class="layui-input-inline" style="">\n' +
                      '       <select id="courseType" lay-verify="required">\n' +
                      '        <option value="0">线上</option>\n' +
                      '        <option value="1">线下</option>\n' +
                      '      </select>\n' +
                      '    </div>\n' +
                      '  </div>\n' +
                      '  \n' +
                    '</div>' +
                '<div class="layui-form-item" style="margin-top:10px;">\n' +
                ' \n' +
                '  <div class="layui-inline">\n' +
                '    <label class="layui-form-label">讲师</label>\n' +
                '    <div class="layui-input-inline" style="">\n' +
                '      <input type="text"  disabled value="'+parentTeacher+'" placeholder="" autocomplete="off" class="layui-input">\n' +
                '    </div>\n' +
                '  </div>\n' +
                '  \n' +

                '</div>' +

                    '<div class="layui-form-item">\n' +
                    '  <div class="layui-inline hide" style="width:80%">\n' +
                    '    <label class="layui-form-label">报名时间 <span style="color:red">*</span></label>\n' +
                    '    <div class="layui-input-inline" style="width:70%">\n' +
                    '   <div class="layui-input-inline" style="width: 200px;">'+
                    '      <input type="text" id="bmStartTime" name="enrollTime" placeholder="" autocomplete="off" class="layui-input">\n' +
                    '</div>'+
                    '   <div class="layui-form-mid">-</div>'+
                    '   <div class="layui-input-inline" style="width: 200px;">'+
                    '      <input type="text" id="bmEndTime" name="enrollTime1" placeholder="" autocomplete="off" class="layui-input">\n' +
                    // '      <input type="hidden" id="enrollTime" name="enrollTime" placeholder="" autocomplete="off" class="layui-input">\n' +
                    '</div>'+
                    '    </div>\n' +
                    '  </div>\n' +

                    '</div>'+
                '<div class="layui-form-item">\n' +
                '  <div class="layui-inline hide" style="width:80%">\n' +
                '    <label class="layui-form-label">签到时间 <span style="color:red">*</span></label>\n' +
                '    <div class="layui-input-inline" style="width:70%">\n' +
                '   <div class="layui-input-inline" style="width: 200px;">'+
                '      <input type="text" id="qdStartTime" name="siginTime" placeholder="" autocomplete="off" class="layui-input">\n' +
                '</div>'+
                '   <div class="layui-form-mid">-</div>'+
                '   <div class="layui-input-inline" style="width: 200px;">'+
                '      <input type="text" id="qdEndTime" name="siginTime1" placeholder="" autocomplete="off" class="layui-input">\n' +
                // '      <input type="hidden" id="singinTime" name="singinTime" placeholder="" autocomplete="off" class="layui-input">\n' +
                '</div>'+
                '    </div>\n' +
                '  </div>\n' +

                '</div>'+
                    '<div class="layui-form-item">\n' +
                    '  <div class="layui-inline hide" style="width:80%">\n' +
                    '    <label class="layui-form-label">开课时间 <span style="color:red">*</span></label>\n' +
                    '    <div class="layui-input-inline" style="width:70%">\n' +
                    '   <div class="layui-input-inline" style="width: 200px;">'+
                    '      <input type="text" id="kkStartTime" name="courseTime" placeholder="" autocomplete="off" class="layui-input">\n' +
                    '</div>'+
                    '   <div class="layui-form-mid">-</div>'+
                    '   <div class="layui-input-inline" style="width: 200px;">'+
                    '      <input type="text" id="kkEndTime" name="courseTime1" placeholder="" autocomplete="off" class="layui-input">\n' +
                    // '      <input type="hidden" id="courseTime" name="courseTime" placeholder="" autocomplete="off" class="layui-input">\n' +
                    '</div>'+
                    '    </div>\n' +
                    '  </div>\n' +

                    '</div>'+
                '<div class="layui-form-item">\n' +
                '  <div class="layui-inline hide" style="width:80%">\n' +
                '    <label class="layui-form-label">评估时间 <span style="color:red">*</span></label>\n' +
                '    <div class="layui-input-inline" style="width:70%">\n' +
                '   <div class="layui-input-inline" style="width: 200px;">'+
                '      <input type="text" id="pgStartTime" name="assessTime" placeholder="" autocomplete="off" class="layui-input">\n' +
                '</div>'+
                '   <div class="layui-form-mid">-</div>'+
                '   <div class="layui-input-inline" style="width: 200px;">'+
                '      <input type="text" id="pgEndTime" name="assessTime1" placeholder="" autocomplete="off" class="layui-input">\n' +
                // '      <input type="hidden" id="courseTime" name="courseTime" placeholder="" autocomplete="off" class="layui-input">\n' +
                '</div>'+
                '    </div>\n' +
                '  </div>\n' +


                '</div>'+
                '<div class="layui-form-item">\n' +
                '  <div class="layui-inline" style="width:97%">\n' +
                '    <label class="layui-form-label">评估满意度 </label>\n' +
                '    <div class="layui-input-inline" style="width:72%">\n' +
                '      <input type="text" id="assessDegree" name="assessDegree"  placeholder="" autocomplete="off" class="layui-input">\n' +

                '    </div>\n' +
                '  </div>\n'+

                '</div>' +
                '<div class="layui-form-item">\n' +
                '  <div class="layui-inline" style="width:97%">\n' +
                '    <label class="layui-form-label">上课地点 </label>\n' +
                '    <div class="layui-input-inline" style="width:72%">\n' +
                '      <input type="text" id="courseAddress" name="courseAddress"  placeholder="" autocomplete="off" class="layui-input">\n' +

                '    </div>\n' +
                '  </div>\n'+

                '</div>' +
                '<div class="layui-form-item">\n' +
                ' \n' +
                '  <div class="layui-inline">\n' +
                '    <label class="layui-form-label">课时</label>\n' +
                '    <div class="layui-input-inline" style="">\n' +
                '      <input type="text" name="classHour" autocomplete="off" class="layui-input">\n' +
                '    </div>\n' +
                '  </div>\n' +
                '  <div class="layui-inline">\n' +
                '    <label class="layui-form-label">是否安排考试<span style="color:red">*</span></label>\n' +
                '    <div class="layui-input-inline" style="">\n' +
                '       <select name="ifExamination" id="ifExamination" lay-verify="required">\n' +
                '        <option value="">请选择</option>\n' +
                '        <option value="0">是</option>\n' +
                '        <option value="1">否</option>\n' +
                '      </select>\n' +
                '    </div>\n' +
                '  </div>\n' +

                '  \n' +
                '</div>' +
                    '<div class="layui-form-item">\n' +
                    '  <div class="layui-inline" style="width:97%">\n' +
                    '    <label class="layui-form-label">按人员选择(上课) </label>\n' +
                    '    <div class="layui-input-inline" style="width:72%">\n' +
                    '      <input type="text" id="userName"   placeholder="" autocomplete="off" class="layui-input">\n' +
                    '      <input type="hidden"  name="userIds" user_id="" placeholder="" autocomplete="off" class="layui-input">\n'+
                    '        <div style="float:right;margin: -29px -72px 0px 0px;color:#1E9FFF"><a href="javascript:;" style="color:#1E9FFF" class="addUser">添加</a>\n' +
                    '        <a href="javascript:;" style="color:#1E9FFF" class="clearUser">清空</a></div>\n' +
                    '    </div>\n' +
                    '  </div>\n'+

                    '</div>' +
                '<div class="layui-form-item">\n' +
                '  <div class="layui-inline" style="width:97%">\n' +
                '    <label class="layui-form-label">按部门选择(上课) </label>\n' +
                '    <div class="layui-input-inline" style="width:72%">\n' +
                '      <input type="text" id="deptName"  placeholder="" autocomplete="off" class="layui-input">\n' +
                '      <input type="hidden"  name="deptIds" placeholder="" deptid="" autocomplete="off" class="layui-input">\n'+
                '        <div style="float:right;margin: -29px -72px 0px 0px;color:#1E9FFF"><a href="javascript:;" style="color:#1E9FFF" class="addDept">添加</a>\n' +
                '        <a href="javascript:;" style="color:#1E9FFF" class="clearDept">清空</a></div>\n' +
                '    </div>\n' +
                '  </div>\n'+

                '</div>' +
                '<div class="layui-form-item">\n' +
                '  <div class="layui-inline" style="width:97%">\n' +
                '    <label class="layui-form-label">按角色选择(上课) </label>\n' +
                '    <div class="layui-input-inline" style="width:72%">\n' +
                '      <input type="text" id="userPriv"  placeholder="" autocomplete="off" class="layui-input">\n' +
                '      <input type="hidden"  name="userPrivs" privid="" placeholder="" autocomplete="off" class="layui-input">\n'+
                '        <div style="float:right;margin: -29px -72px 0px 0px;color:#1E9FFF"><a href="javascript:;" style="color:#1E9FFF" class="addPriv">添加</a>\n' +
                '        <a href="javascript:;" style="color:#1E9FFF" class="clearPriv">清空</a></div>\n' +
                '    </div>\n' +
                '  </div>\n'+

                '</div>' +





                    '</form></div>',
                success: function (res) {
                    $('#courseType').val(parentcourseType).attr('disabled','disabled')
                    form.render()
                    $(".addUser").on("click",function(){
                        user_id = "userName";
                        $.popWindow("/common/selectUser");
                    });
                    $(".addDept").on("click",function(){
                        dept_id = "deptName";
                        $.popWindow("/common/selectDept");
                    });
                    $(".addPriv").on("click",function(){
                        priv_id = "userPriv";
                        $.popWindow("/common/selectPriv");
                    });
                    $('.clearUser').click(function () {
                        $("#userName").val("");
                        $("#userName").attr('username','');
                        $("#userName").attr('dataid','');
                        $("#userName").attr('user_id','');
                        $("#userName").attr('userprivname','');
                    });
                    $('.clearDept').click(function () {
                        $("#deptName").val("");
                        $("#deptName").attr('deptName','');
                        $("#deptName").attr('deptid','');
                    });
                    $('.clearPriv').click(function () {
                        $("#userPriv").val("");
                        $("#userPriv").attr('userpriv','');
                        $("#userPriv").attr('privid','');
                    });
                    laydate.render({
                        elem:'#bmStartTime'
                        ,trigger: 'click'//呼出事件改成click
                        ,type:'datetime'
                        ,format: 'yyyy-MM-dd HH:mm:ss'
                        // ,value:new Date()
                    });
                    laydate.render({
                        elem:'#bmEndTime'
                        ,trigger: 'click'//呼出事件改成click
                        ,type:'datetime'
                        ,format: 'yyyy-MM-dd HH:mm:ss'
                        // ,value:new Date()
                    });
                    laydate.render({
                        elem:'#qdStartTime'
                        ,trigger: 'click'//呼出事件改成click
                        ,type:'datetime'
                        ,format: 'yyyy-MM-dd HH:mm:ss'
                        // ,value:new Date()
                    });
                    laydate.render({
                        elem:'#qdEndTime'
                        ,trigger: 'click'//呼出事件改成click
                        ,type:'datetime'
                        ,format: 'yyyy-MM-dd HH:mm:ss'
                        // ,value:new Date()
                    });
                    laydate.render({
                        elem:'#kkStartTime'
                        ,trigger: 'click'//呼出事件改成click
                        ,type:'datetime'
                        ,format: 'yyyy-MM-dd HH:mm:ss'
                        // ,value:new Date()
                    });
                    laydate.render({
                        elem:'#kkEndTime'
                        ,trigger: 'click'//呼出事件改成click
                        ,type:'datetime'
                        ,format: 'yyyy-MM-dd HH:mm:ss'
                        // ,value:new Date()
                    });
                    laydate.render({
                        elem:'#pgStartTime'
                        ,trigger: 'click'//呼出事件改成click
                        ,type:'datetime'
                        ,format: 'yyyy-MM-dd HH:mm:ss'
                        // ,value:new Date()
                    });
                    laydate.render({
                        elem:'#pgEndTime'
                        ,trigger: 'click'//呼出事件改成click
                        ,type:'datetime'
                        ,format: 'yyyy-MM-dd HH:mm:ss'
                        // ,value:new Date()
                    });
                    if (type == 1) {
                        $.ajax({
                            url: '/trCourseSchedule/showDetils?scheduleId=' + courseId,
                            type: 'get',
                            dataType: 'json',
                            success: function (res) {
                                var str = ''
                                $('input[name="scheduleName"]').val(undefind_nullStr(res.object.scheduleName)) //课程名称
                                $('input[name="classHour"]').val(undefind_nullStr(res.object.classHour)) //课时
                                // $('[name="courseType"]').val(undefind_nullStr(res.object.courseType)) //课程类别
                                // $('[name="courseManager"]').val(undefind_nullStr(res.object.courseManager)) //讲师


                                $('[name="ifExamination"]').val(undefind_nullStr(res.object.ifExamination)) //是否安排考试
                                $('input[name="assessDegree"]').val(undefind_nullStr(res.object.assessDegree)) //评估满意度
                                $('input[name="courseAddress"]').val(undefind_nullStr(res.object.courseAddress)) //上课地点
                                $('#userName').val(undefind_nullStr(res.object.userName)) //上课地点
                                $('#deptName').val(undefind_nullStr(res.object.deptName)) //上课地点
                                $('#userPriv').val(undefind_nullStr(res.object.userPrivName)) //上课地点
                                $('#userName').attr('user_id',undefind_nullStr(res.object.userIds)) //评估时间
                                $('#deptName').attr('deptid',undefind_nullStr(res.object.deptIds)) //评估满意度
                                $('#userPriv').attr('privid',undefind_nullStr(res.object.userPrivs)) //上课地点
                                $('#bmStartTime').val(undefind_nullStr(res.object.enrollTime)) //报名时间
                                $('#bmEndTime').val(undefind_nullStr(res.object.enrollTime1))  //报名时间


                                $('#qdStartTime').val(undefind_nullStr(res.object.siginTime)) //报名时间
                                $('#qdEndTime').val(undefind_nullStr(res.object.siginTime1))  //报名时间


                                $('#kkStartTime').val(undefind_nullStr(res.object.courseTime)) //报名时间
                                $('#kkEndTime').val(undefind_nullStr(res.object.courseTime1))  //报名时间


                                $('#pgStartTime').val(undefind_nullStr(res.object.assessTime)) //报名时间
                                $('#pgEndTime').val(undefind_nullStr(res.object.assessTime1))  //报名时间
                                form.render();
                            }
                        })
                    } else if (type == 2) {
                        $.ajax({
                            url: '/course/showDetails?id=' + courseId,
                            type: 'get',
                            dataType: 'json',
                            success: function (res) {
                                var str = ''
                                $('input[name="courseName"]').val(undefind_nullStr(res.object.courseName)) //课程名称

                                $('[name="courseType"]').val(undefind_nullStr(res.object.courseType)) //课程类别
                                if (res.object.attachmentList.length > 0) {
                                    for (var i = 0; i < res.object.attachmentList.length; i++) {
                                        str += '<div class="dech" deUrl="' + res.object.attachmentList[i].attUrl + '"><a href="<%=basePath %>download?' + res.object.attachmentList[i].attUrl + '" NAME="' + res.object.attachmentList[i].attachName + '*"><img style="width:16px;" src="/img/file/cabinet@.png"/>' + res.object.attachmentList[i].attachName + '</a><img class="deImgs" style="margin-left:5px;cursor: pointer;" src="/img/file/icon_deletecha_03.png"/><input type="hidden" class="inHidden" value="' + res.object.attachmentList[i].aid + '@' + res.object.attachmentList[i].ym + '_' + res.object.attachmentList[i].attachId + ',"></div>';
                                    }
                                } else {
                                    str = '';
                                }
                                $('#Attachment').html(str)
                                $('input[name="courseName"]').attr('readonly', 'readonly')
                                $('#uploadimgform').hide();
                                $('#couseTile').show();
                                form.render();
                            }
                        })
                    }
                },
                yes: function (index, layero) {

                    if($('#bmStartTime').val()==''&&$('#bmEndTime').val()==''){
                        $.layerMsg({content:'请选择报名时间',icon:2});
                        return false;
                    }
                    if($('#qdStartTime').val()==''&&$('#qdEndTime').val()==''){
                        $.layerMsg({content:'请选择签到时间',icon:2});
                        return false;
                    }
                    if($('#kkStartTime').val()==''&&$('#kkEndTime').val()==''){
                        $.layerMsg({content:'请选择开课时间',icon:2});
                        return false;
                    }
                    if($('#pgStartTime').val()==''){
                        $.layerMsg({content:'请选择评估时间',icon:2});
                        return false;
                    }
                    //必填项为 是否安排考试
                    if($('#ifExamination option:checked').text()=='请选择'){
                        $.layerMsg({content:'请选择是否安排考试',icon:2});
                        return false;
                    }

                    $('input[name="userIds"]').val($('#userName').attr('user_id'))
                    $('input[name="deptIds"]').val($('#deptName').attr('deptid'))
                    $('input[name="userPrivs"]').val($('#userPriv').attr('privid'))
                    if (type == 0) {
                        $('#ajaxform').attr('action', '/trCourseSchedule/add?courseId=' + parentcourseId)
                    } else {
                        $('#ajaxform').attr('action', '/trCourseSchedule/change?scheduleId=' + courseId + '&courseId=' + parentcourseId)
                    }

                    $('#ajaxform').ajaxSubmit({
                        dataType: 'json',
                        success: function (res) {
                            layer.closeAll();
                            var currentPage = 1;
                            table.reload('Settlement', {
                                url: '/trCourseSchedule/showSome?courseId=' + parentcourseId,
                                data: {page: currentPage},
                                page: {
                                    curr: currentPage
                                }
                            })
                        }
                    })


                },
                btn2: function (index, layero) {

                },
                cancel: function (index, layero) {

                }
            });
        }
    });


    $('#courseType').click(function () {
        layer.open({
            type: 2,
            skin: 'layui-layer-rim', //加上边框
            area: ['500px', '500px'], //宽高
            shadeClose:true,
            title: '课程类别管理',
            maxmin: true,
            btn: ['<div style="background:none;border:none;color:#fff" id="lay-submit">确定</div>', '取消'],
            content: '/equipmentType/indexList',
            yes: function () {
                window.location.reload();
            }
        })
    })

    //        删除
    function publicDeletes(url, ids, tableIns, table) {
        layer.confirm('确定要删除吗?', {icon: 3, title: '提示'}, function (index) {
            var data = {
                scheduleId: ids
            }
            var res = toAjaxT(url, data);
            layer.msg(res.msg)
            if (res.code == 0) {
                try {
                    if (ids.substring(ids.length - 1) == ",") {
                        ids = ids.substring(0, ids.length - 1);
                    }
                    var dataSize = ids.split(",");
                    var dataAll = table.cache[tableIns.config.id];
                    if (dataAll.length == dataSize.length) {
                        //得到当前页
                        var page = $(".layui-laypage-skip .layui-input").val();

                        if (page > 1) {
                            tableIns.reload({
                                    page: {
                                        curr: page - 1 //重新从第 1 页开始
                                    }
                                }
                            );
                        } else {
                            tableIns = tableIns.reload();
                        }
                    } else {
                        tableIns = tableIns.reload();
                    }
                } catch (e) {
                    tableIns.reload();
                }
            }
            layer.close(index);
        });
    }

    function deleteChatment(data, element) {

        layer.confirm('<fmt:message code="workflow.th.que" />？', {
            btn: ['<fmt:message code="global.lang.ok" />', '<fmt:message code="depatement.th.quxiao" />'], //按钮
            title: "<fmt:message code="notice.th.DeleteAttachment" />"
        }, function () {
            //确定删除，调接口
            $.ajax({
                type: 'get',
                url: '/delete',
                dataType: 'json',
                data: data,
                success: function (res) {

                    if (res.flag == true) {
                        layer.msg('<fmt:message code="workflow.th.delsucess" />', {icon: 6});
//                                     var file = $('[name="file"]')
//                                     file.after(file.clone().val(""));
//                                     file.remove();
                        element.remove();
                    } else {
                        layer.msg('<fmt:message code="lang.th.deleSucess" />', {icon: 6});
                    }
                }
            });

        }, function () {
            layer.closeAll();
        });
    }

    //将毫秒数转为yyyy-MM-dd格式时间
    function format(t) {
        var str = "";
        var nnow = new Date(t);
        var year = nnow.getFullYear();
        var month = nnow.getMonth() + 1;
        var day = nnow.getDate();
        str = year + "-" + month + "-" + day;
        return str;
    }

    //获取当前时间  年月日
    function nowformat() {
        var nstr = "";
        var now = new Date();
        var nyear = now.getFullYear();
        var nmonth = now.getMonth() + 1;
        var nday = now.getDate();
        if (nmonth < 10) {
            nmonth = "0" + nmonth;
        }
        if (nday < 10) {
            nday = "0" + nday;
        }
        nstr = nyear + "-" + nmonth + "-" + nday;
        return nstr;
    }



    $('#print').click(function () {
        $('#print').hide();
        $('#back').hide();
        window.print();
        $('#print').show();
        $('#back').show();
    })
</script>
<script>


</script>

</body>


</html>